<?php
  
	//set le titre drupal
	drupal_set_title('Probl&egrave;me &agrave; l\'emprunt des albums !');

	//ajoute le CSS pour la vue
	drupal_add_css('bdbdec/view/css/borrowStep3.css');
	
	//rend la vue
	if (!isset($booksUnBorrowable) || (!$booksUnBorrowable['unknown'] && !$booksUnBorrowable['reserved'] && !$booksUnBorrowable['late']))
			$controller->forward('borrow');
	else if (isset($booksUnBorrowable['late']) && $booksUnBorrowable['late'])
	{
		echo '
		<div class="unknownBD"><strong>ALBUMS A EMPRUNTER</strong><br />Vous pouvez forcer l\'emprunt de la liste d\'albums suivante :
			<ul>';
		foreach($booksUnBorrowable['late'] as $cotation)
			echo '<li>'.$cotation.'</li>';
		echo '
			</ul>
		</div>
		<div class="formBox">
			<form action="./bdbdec.php?action=borrowStep3&amp;uid='.$userBorrowed->getId().'" method="post">
				<input type="hidden" name="nbBooksBorrowed" value="'.$nbBooksBorrowed.'"/>
				<input type="hidden" name="motif" value="'.$motif.'"/>
				<input type="hidden" name="forceBorrowLate" value="true"/>
				<input type="hidden" name="username" value="'.$username.'"/>';
		foreach($booksUnBorrowable['late'] as $_cotation)
			echo '<input type="hidden" name="bookBorrowed[]" value="'.$_cotation.'"/>';
			
			echo '<input type="submit" value="Forcer les emprunts des albums malgr&eacute; le retard !" />
			</form>
		</div>
		';
			
	}
	else
	{
		if (isset($booksUnBorrowable['unknown']) && $booksUnBorrowable['unknown'])
		{
			echo '<div class="unknownBD"><strong>REFERENCES INCONNUES</strong><br />Les r&eacute;f&eacute;rences (cotes) suivantes sont inconnues du syst&egrave;me :
			<ul>';
			foreach($booksUnBorrowable['unknown'] as $cotation)
				echo '<li>'.$cotation.'</li>';
			echo '</ul></div>';
		}
		if (isset($booksUnBorrowable['reserved']) && $booksUnBorrowable['reserved'])
		{
				echo '<div class="unknownBD"><strong>ALBUMS RESERVES</strong><br />Les albums suivants sont  r&eacute;serv&eacute;s :
				<ul>';
				foreach($booksUnBorrowable['reserved'] as $id)
				{
					$album = book::singleton($id, 'id');
					echo '<li>'.$album->getName().' ('.$album->getCotation().')</li>';
				}
				echo '</ul></div>';
			echo '
			<div class="formBox">
				<form action="./bdbdec.php?action=borrowStep3&amp;uid='.$userBorrowed->getId().'" method="post">
					<input type="hidden" name="forceBorrowReserved" value="true"/>
					<input type="hidden" name="nbBooksBorrowed" value="'.$nbBooksBorrowed.'"/>
					<input type="hidden" name="motif" value="'.$motif.'"/>
					<input type="hidden" name="forceBorrowLate" value="true"/>
					<input type="hidden" name="username" value="'.$username.'"/>';
			foreach($booksUnBorrowable['reserved'] as $_cotation)
			{
				$album = book::singleton($_cotation, 'cotation');
				echo '<input type="hidden" name="bookBorrowed[]" value="'.$album->getCotation().'"/>';
			}
				
				echo '<input type="submit" value="Forcer les emprunts des albums r&eacute;serv&eacute;s !" />
				</form>
			</div>
			';
		}
	}
	echo '<center><a href="./bdbdec.php?action=borrowStep2&username='.urlencode($username).'">Retour</a></center>';
	
?>
